package com.mxpio.erp.common.sales.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@Schema(description="销售订单明细行计划明细（通知单明细维护加上仓单明细行数据维度（计划发货数、计划退货数））")
public class SOLinePlanDetailVO implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;

	@Schema(description = "行号")
	@Id
	private String lineNo;

	@Schema(description = "通知单号")
	@Id
	private String noticeNo;

	@Schema(description = "来源单号")
	private String originBizNo;

	@Schema(description = "来源单行号")
	private String originBizLineNo;

	@Schema(description = "顺序号")
	private String sort;

	@Schema(description = "物料编码")
	private String itemCode;

	@Schema(description = "物料名称")
	private String itemName ;

	@Schema(description = "规格型号")
	private String itemSpec;

	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Schema(description = "批次号")
	private String lotNo;

	@Schema(description = "子批次索引号")
	private String subLotIndex;

	@Schema(description = "数量（通知单）")
	private BigDecimal quantity;

	@Schema(description = "图号")
	private String drawingNo;

	@Schema(description = "是否加入主计划")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private Boolean joinMainPlan ;

	@Schema(description = "客户存货名称")
	private String cstStoreName;

	@Schema(description = "客户主计量")
	private String cstMainMetering;

	@Schema(description = "交付日期")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date deliverDate;

	@Schema(description = "指定交付日期")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date appointDeliverDate;

	@Schema(description = "税率")
	private BigDecimal taxRate ;

	@Schema(description = "无税单价")
	private BigDecimal untaxPrice;

	@Schema(description = "含税单价")
	private BigDecimal taxPrice;

	@Column(name = "UNTAX_AMOUNT_")
	@Schema(description = "无税金额")
	private BigDecimal untaxAmount;

	@Schema(description = "税额")
	private BigDecimal tax;

	@Schema(description = "价税合计")
	private BigDecimal totalAmount;

	@Schema(description = "收货地址")
	private String address;

	@Schema(description = "收货人")
	private String consignee;

	@Schema(description = "联系电话")
	private String addrTel;

	@Schema(description = "备注")
	private String memo;

	@Schema(description = "仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;

	@Schema(description = "仓单单号")
	private String woBizNo;

	@Schema(description = "仓单行号")
	private String woBizLineNo;

/*	@Schema(description = "计划执行数量（仓单明细行）")
	private BigDecimal planQuantity;

	@Schema(description = "计划退货数量（仓单明细行）")
	private BigDecimal planRejectQuantity;*/

	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}
}
